/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2024-04-03
 * Time: 9:19
 */


class Solution {
    public boolean evaluateTree(TreeNode root) {
        if(root.left == null) {//可以不用判断右
            return root.val == 0 ? false : true;
        }
        boolean left = evaluateTree(root.left);
        boolean right = evaluateTree(root.right);
        return root.val == 2 ? left | right : left & right;
    }
}